package com.scau.RBAC.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * 数据库配置工具类，负责加载和获取数据库配置
 */
public class DBConfig {
    private static Properties properties = new Properties();

    static {
        try (InputStream in = DBConfig.class.getClassLoader().getResourceAsStream("application.properties")) {
            properties.load(in);
        } catch (IOException e) {
            throw new RuntimeException("加载数据库配置文件失败", e);
        }
    }

    public static String getProperty(String key) {
        return properties.getProperty(key);
    }

    public static String getProperty(String key, String defaultValue) {
        return properties.getProperty(key, defaultValue);
    }
}
